<?php

/**
 * @author edson
 * @copyright 2011
 */

Class CDrawPageReg
{
    //.enviando nuevos cambios.......................
    
    //agregando nueva variable 
    
    public static $instance2;
    public static $instance;
     
    function __construct()
    {
      
        
    }
      function DrawinputDate($items,$name){
        $data=date("m/d/Y");
    ?>
        <p>
     <label> <?php echo $items;?> </label><input id='<?php echo $items;?>' class="inputDate" value='<?php echo $data;?>' name='<?php echo $name;?>' onclick="data('<?php echo $items?>')"/>  </label>  
    </p>
    <?php
    }
    function  DrawHead($action,$name,$method,$NAME){echo "<div id='register-box'>\n";echo "<form action='$action' method='$method' name='$name'>\n";echo "<h2>$NAME</h2>\n";}
    function  DrawFoot(){
        echo "</form>";
        echo "</div>";}
    function  DrawTextBox()
    {   
        if(count(func_get_args())>1)
        {
        $item=func_get_args();
       
        $items=$item['0'];
        $tabla=array();
        $tabla=$item['1'];
        $tabla=$tabla['0'] ;
          //var_dump($tabla);
            ?>
               <p>
               <?php
                    foreach($items as $id => $valor)
                    {
                        echo "<label>".$valor."<input type='text' name='$valor' class='input-text' id='$id' value='$tabla[$id]'>"."</label>";
                        
                    }
               
               ?>
               
               </p> 
            
        
        
        <?php
            
        }
        else
        {       $items=func_get_args();
                    $items=$items['0'];
            ?>
               <p>
               <?php
                    foreach($items as $id => $valor)
                    {
                        echo "<label>".$valor."<input type='text' name='$valor' class='input-text' id='$id'>"."</label>";
                        
                    }
               
               ?>
               
               </p> 
            
        
        
        <?php
        }
        
    }
    function DrawSelect($table,$campos,$NAME,$update=-1)//especificar los campos que deben de aparecer 
    {
        
        
        $query="select " ;
        foreach($campos as $campo => $valor){$query=$query.$valor.",";}
        $query= substr($query,0,strlen($query)-1);
         $query=$query." from ".$table;
        
        $table2=CModelo::getInstance()->getData($query);
        //var_dump($table2);
       // if(!$update){}
        ?>
        
        
        <label><?php echo $NAME;?>
        <select name=<?php echo $NAME;?> class="input_pulldown">
        <?php
        foreach($table2 as $row =>$colum)
        {
        $tabla=$colum;$select="";$i=0;
        foreach($tabla as $campo=>$valor)
        {
            //if($i>0){$select=$select."<option value=".$tabla[$campo]."> ";}
            if($i<=0){
                if($update==$valor){
                $select=$select."<option value=".$valor." selected='selected'> ";}
                else{
                //if($update!=$valor)
                $select=$select."<option value=".$valor.">";
                }
            }
            //$select=$select.$tabla[$campo].",";$i=$i+1;
            if($i>0){
                $select=$select.$tabla[$campo].",";
                }
            $i=$i+1;
        }
        echo $select."</option>\n";
        //echo "<option value=".$tabla['idOfi'].">".$tabla['DirOfi']."</option>\n";    
        }
        ?>
        </select>       
        </label>
        
    
    <?php
    }
    function DrawRadioButton($items,$name,$update=-1)
    {
      
      echo "<p>";
      
      foreach($items as $id => $valor)
                    {
                        if($update==$valor){
                        echo "<label>".$id."<input type='radio' class=\"input-radio\" name='$name' value='$valor' checked=''>"."</label>\n";
                        }else{
                        echo "<label>".$id."<input type='radio' class=\"input-radio\" name='$name' value='$valor'>"."</label>\n";
                    }
                    }
                    
      
      
      echo "</p>";
      
        
        
    }
    
    function DrawSubmmit($nombre){echo "<input class='submit_button' type='submit' name=$nombre value='$nombre'>";}
    public static function getInstance()
	{
		//echo "<div id=register-box>";
        if(self::$instance==null)
		  self::$instance=new CDrawPageReg();
	//   echo "</div>";	  
		return  self::$instance;
	   
    
    }	
    
    
}

?>